import { View } from "../../../../../mvc/core/View";
import { IToolTipItem } from "../../../../../../com/mui/manager/IToolTipItem";
import { LayerManager } from "../../../../manager/LayerManager";
import { ObjCreate } from "../../../common/ObjCreate";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { EventName } from "../../../../mvc/EventName";
import { DataEvent } from "../../../../events/DataEvent";
import { EffectManager } from "../../../../manager/EffectManager";
import { GuideTipsManager } from "../../../../manager/GuideTipsManager";
import { Language } from "../../../../../../extend/language/Language";
import { Cache } from "../../../../cache/Cache";
import { CareerUtil } from "../../../common/util/CareerUtil";
import { GLoadedButton } from "../../../../../../com/mui/controls/GLoadedButton";
import { GuideTips } from "../../../guide/GuideTips";
type int = number;
//class RuneBtn
    
    export  class RuneBtn extends View implements IToolTipItem
    {
        constructor()
        {
            super();
            if (RuneBtn._instance) 
            {
                throw new Error("RuneBtn.as single model");
            }
            layer = LayerManager.rightTopUILayer;
            this._loadedBtn = ObjCreate.createGLoadedButton(ResFileConst.RuneBtn, 0, 0, 60, 50, this);
            addEventListener(flash.events.MouseEvent.CLICK, this.onClickHandler);
            Dispatcher.addEventListener(EventName.ShowGameMainUI, this.onShowGameMainUI);
            return;
        }

        /* internal  */onShowGameMainUI(arg1: DataEvent): void
        {
            var loc1=arg1.data as Boolean;
            if (loc1) 
            {
                this.show();
            }
            else 
            {
                this.hide();
            }
            return;
        }

        /* internal  */onClickHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RuneGuideBtnClick));
            this.clear();
            return;
        }

        /* internal  */clear(): void
        {
            EffectManager.glowFilterUnReg(this);
            if (this._tips && this._tips.parent == this) 
            {
                GuideTipsManager.hideGuideTips();
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            if (!this._glowEd) 
            {
                this._glowEd = true;
                EffectManager.glowFilterReg(this, null, 1, 10, 0, 20);
                this._tips = GuideTipsManager.getGuideTips(GuideTipsManager.Dir_TR, Language.getString(26514), null, null, -1, -1, true, this.onClickHandler, 60000);
                this._tips.x = 20;
                this._tips.y = 50;
                addChild(this._tips);
            }
            return;
        }

        public /* override */ hide(): void
        {
            this.clear();
            super.hide();
            if (!(Cache.instance.rune.runeInfo && Cache.instance.rune.runeInfo.runeGuide == 0 && CareerUtil.isGradeCareer())) 
            {
                Dispatcher.removeEventListener(EventName.ShowGameMainUI, this.onShowGameMainUI);
            }
            return;
        }

        public get toolTipData()
        {
            return null;
        }

        public set toolTipData(arg1)
        {
            return;
        }

        public static getInstance(): RuneBtn
        {
            if (!RuneBtn._instance) 
            {
                RuneBtn._instance = new RuneBtn();
            }
            return RuneBtn._instance;
        }

        public static hasInstance(): Boolean
        {
            return !(RuneBtn._instance == null);
        }

        /* internal */ /* var */_loadedBtn: GLoadedButton;

        /* internal */ /* var */_tips: GuideTips;

        /* internal */ /* var */_glowEd: Boolean;

        /* internal */ static /* var */_instance: RuneBtn;
    }
